/*
		ServEngine framework library
		A library to fast develop JEE online applications
	
		Copyright 2008 José Ignacio de Córdoba Álvaro

		Licensed under the Apache License, Version 2.0 (the "License");
		you may not use this file except in compliance with the License.
		You may obtain a copy of the License at

				http://www.apache.org/licenses/LICENSE-2.0

		Unless required by applicable law or agreed to in writing, software
		distributed under the License is distributed on an "AS IS" BASIS,
		WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
		See the License for the specific language governing permissions and
		limitations under the License.
	
		Jose Ignacio de Cordoba Alvaro
		http://ignacio.decordoba.com
*/

package com.servengine.log;

import java.io.Serializable;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
/*@NamedQueries ({
	@NamedQuery(name = "LogEntry.findByModuleAndAction", query = "select o from LogEntry o where o.portalid = :portalid and o.module = :module and o.action = :action and o.date >= :from and o.date <= :to"),
	@NamedQuery(name = "LogEntry.findByModuleActionAndMethod", query = "select o from LogEntry o where o.portalid = :portalid and o.module = :module and o.action = :action and o.methodName = :methodName and o.date >= :from and o.date <= :to")
})*/
public class LogEntry implements Serializable,Comparable<LogEntry>
{
	Integer id;
	String portalid, module, action,methodName, data, ipaddress;
	Integer userId;
	java.util.Date date;
	
	public LogEntry() {}
	
	public LogEntry(String portalid, Integer userId, String module, String action,
									String methodName, String data, String ipaddress)
	{
		this.portalid=portalid;
		this.module=module;
		this.action=action;
		this.methodName=methodName;
		this.data=data;
		this.userId=userId;
		this.date=new java.util.Date();
		this.data=data;
		this.ipaddress=ipaddress;
	}

	@Id @GeneratedValue
	public Integer getId()
	{
		return id;
	}

	public boolean equals(Object o)
	{
		return ((LogEntry)o).getId().equals(id);
	}

	public String getPortalid()
	{
		return portalid;
	}

	public String getModule()
	{
		return module;
	}

	public String getAction()
	{
		return action;
	}

	public String getMethodName()
	{
		return methodName;
	}

	public String getData()
	{
		return data;
	}

	public Integer getUserId()
	{
		return userId;
	}

	public Date getDate()
	{
		return date;
	}

	public int compareTo(LogEntry t)
	{
		return date.compareTo(t.getDate());
	}

	public String getIpaddress()
	{
		return ipaddress;
	}

	@Id @GeneratedValue
	public void setId(Integer id)
	{
		this.id = id;
	}

	public void setPortalid(String portalid)
	{
		this.portalid = portalid;
	}

	public void setModule(String module)
	{
		this.module = module;
	}

	public void setAction(String action)
	{
		this.action = action;
	}

	public void setMethodName(String methodName)
	{
		this.methodName = methodName;
	}

	public void setData(String data)
	{
		this.data = data;
	}

	public void setIpaddress(String ipaddress)
	{
		this.ipaddress = ipaddress;
	}

	public void setUserId(Integer userpkey)
	{
		this.userId = userpkey;
	}

	public void setDate(Date date)
	{
		this.date = date;
	}
}
